home *** CD-ROM | disk | FTP | other *** search
- /*
- * MUI - Exchange V2.00
- *
- * © 1994-95 by Marc Schröer ; T.O.M. Software Wuppertal
- *
- * email: schroeer@dekanat.informatik.uni-dortmund.de
- * marc@tom.anubis.sub.de
- *
- * smail: Marc-Christian Schröer
- * Mählersbeck 120
- * D-42279 Wuppertal
- * Germany
- *
- *
- * Date Author Comment
- * -----------------------------------------------------------------------
- * 20.11.1993 mcs first Public-Release (V1.00)
- * 30.11.1993 mcs APPICON tooltype implemented
- * 04.12.1993 mcs more tooltypes, Remove All
- * 23.12.1993 mcs CxTranslate
- * 17.02.1994 mcs Bugs removed, adjusted to MUI 2.0
- * 03.02.1994 mcs SAS/C-Version
- * 08.05.1994 mcs minor enhancements, multi-select
- * 23.07.1994 mcs new layout
- * 29.01.1995 mcs enhancements, MUI 2.3 adjustments
- * 30.01.1995 mcs second Public-Release / AmiNet (V2.00)
- */
-
- #include <clib/muimaster_protos.h>
- #include <clib/commodities_protos.h>
- #include <pragmas/muimaster_pragmas.h>
- #include <pragmas/commodities_pragmas.h>
- #include <libraries/mui.h>
- #include <libraries/commodities.h>
-
- #include <Defines.h> // some personal definitions
-
- #include "Exchange_protos.h" // machine-generated prototypes
-
- #include "Comm.h"
- #include "Exchange_cat.h" // localizing file
-
- #define VERSION "2.00" // global Version
-
- // some enums for IDs
-
- enum{ ID_ABOUT=1, ID_QUIT, ID_REMOVESEL, ID_ACTIVATESEL, ID_DEACTIVATESEL, ID_INTERFACESEL,
- ID_SHOWSEL, ID_HIDESEL, ID_REMOVE, ID_TOGGLE, ID_INTERFACE, ID_SHOW,
- ID_HIDE, ID_LV_ACTIVE, ID_ICONIFY, ID_HOTKEY, ID_DEACTIVATEALL, ID_ACTIVATEALL,
- ID_MENUHELP, ID_REMOVEALL, ID_DOUBLE, ID_DEACTIVATE, ID_ACTIVATE };
-
- // global variables
-
- extern struct Catalog *ExchangeCatalog;
-
- struct Library *MUIMasterBase;
- struct Library *CxBase;
- struct IntuitionBase *IntuitionBase;
- struct Library *IconBase, *LocaleBase;
-
- Object *AP_ExChange, *WN_Main, *LV_Broker, *FT_Info, *BT_Toggle, *BT_Remove,
- *BT_Show, *BT_Hide, *BT_DeActAll, *BT_ActAll, *BT_Icon, *BT_Quit, *BT_RemoveAll,
- *BT_ActSel, *BT_DeActSel, *BT_RemoveSel, *BT_ShowSel, *BT_HideSel,
- *TX_Desc;
-
- struct MsgPort *TPort;
- struct timerequest *TRequest;
- struct Message *TMsg;
- ULONG TSignal;
- UBYTE **TTypes;
- BOOL AppIcon = FALSE;
- BOOL set_able = FALSE;
- char *Pages[4];
- char *CycleEntries[3];
-
- __saveds __asm struct BrokerCopy *BrokerListConFunc(register __a0 struct Hook *hook, register __a2 APTR mem_pool, register __a1 struct BrokerCopy *b)
- {
- struct BrokerCopy *bc;
-
- if(bc = AllocVec(sizeof(struct BrokerCopy), MEMF_ANY))
- CopyMem(b, bc, sizeof(struct BrokerCopy));
-
- return(bc);
- }
-
- __saveds __asm LONG BrokerListDesFunc(register __a0 struct Hook *hook, register __a2 APTR mem_pool, register __a1 struct BrokerCopy *bc)
- {
- if(bc)
- FreeVec(bc);
-
- return(0);
- }
-
- __saveds __asm void BrokerListDspFunc(register __a0 struct Hook *hook, register __a2 char **array, register __a1 struct BrokerCopy *bc)
- {
- static UBYTE active_str[20];
-
- if(bc)
- {
- *array++ = bc -> bc_Name;
-
- if(bc -> bc_Flags & COF_ACTIVE)
- sprintf(active_str, "\0330%s", GetExchangeString(Active));
- else
- sprintf(active_str, "\0333%s", GetExchangeString(Inactive));
-
- *array = active_str;
- }
- else
- {
- *array++ = GetExchangeString(ColName);
- *array++ = GetExchangeString(ColState);
- }
- }
-
- __saveds __asm LONG BrokerListCmpFunc(register __a0 struct Hook *hook, register __a2 struct BrokerCopy *bc1, register __a1 struct BrokerCopy *bc2)
- {
- return(stricmp(bc2 -> bc_Name, bc1 -> bc_Name));
- }
-
- __saveds __asm void BrokerListBrkFunc(register __a0 struct Hook *hook, register __a2 Object *obj, register __a1 CxMsg *cm)
- {
- if((CxMsgType(cm) == CXM_COMMAND) && (CxMsgID(cm) == CXCMD_LIST_CHG))
- RefreshBrokerList();
-
- if((CxMsgType(cm) == CXM_IEVENT) && (CxMsgID(cm) == ID_HOTKEY))
- {
- set(AP_ExChange, MUIA_Application_Iconified, FALSE);
- set(WN_Main, MUIA_Window_Open, TRUE);
- }
- }
-
- __saveds __asm LONG SelectNameRXFunc(register __a0 struct Hook *hook, register __a2 Object *appl, register __a1 ULONG *arg)
- {
- char *name;
-
- if(name = (char *)*arg)
- {
- ULONG pos;
-
- if(pos = FindBrokerName(name))
- {
- set(LV_Broker, MUIA_List_Active, pos);
- DoMethod(LV_Broker, MUIM_List_Jump, pos);
-
- return(RETURN_OK);
- }
- }
- return(RETURN_ERROR);
- }
-
- __saveds __asm LONG SelectTaskRXFunc(register __a0 struct Hook *hook, register __a2 Object *appl, register __a1 ULONG *arg)
- {
- ULONG task;
-
- if(task = *((ULONG *)*arg))
- {
- ULONG pos;
-
- if(pos = FindBrokerTask(task))
- {
- set(LV_Broker, MUIA_List_Active, pos);
- DoMethod(LV_Broker, MUIM_List_Jump, pos);
-
- return(RETURN_OK);
- }
- }
-
- return(RETURN_ERROR);
- }
-
- void __saveds __asm MouseFunc(register __a2 Object *Help, register __a1 Object **Obj)
- {
- LONG udata = NULL;
-
- if(*Obj)
- get(*Obj, MUIA_UserData, &udata);
-
- set(TX_Desc, MUIA_Text_Contents, udata);
- }
-
- struct Hook MouseHook = { {NULL, NULL}, (void *)MouseFunc, NULL, NULL };
- struct Hook SelectNameRXHook = { {NULL, NULL}, (void *)SelectNameRXFunc, NULL, NULL };
- struct Hook SelectTaskRXHook = { {NULL, NULL}, (void *)SelectTaskRXFunc, NULL, NULL };
- struct Hook BrokerListConHook = { {NULL, NULL}, (void *)BrokerListConFunc, NULL, NULL };
- struct Hook BrokerListDesHook = { {NULL, NULL}, (void *)BrokerListDesFunc, NULL, NULL };
- struct Hook BrokerListDspHook = { {NULL, NULL}, (void *)BrokerListDspFunc, NULL, NULL };
- struct Hook BrokerListCmpHook = { {NULL, NULL}, (void *)BrokerListCmpFunc, NULL, NULL };
- struct Hook BrokerListBrkHook = { {NULL, NULL}, (void *)BrokerListBrkFunc, NULL, NULL };
-
- struct NewMenu MenuList[] =
- {
- { NM_TITLE, "", 0, 0, 0, 0 },
- { NM_ITEM, "", "?", 0, 0, (APTR) ID_ABOUT },
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0 },
- { NM_ITEM, "", "I", 0, 0, (APTR) ID_ICONIFY },
- { NM_ITEM, "", "Q", 0, 0, (APTR) ID_QUIT },
-
- { NM_TITLE, "", 0, 0, 0, 0 },
- { NM_ITEM, "", "A", 0, 0, (APTR) ID_ACTIVATE },
- { NM_ITEM, "", "D", 0, 0, (APTR) ID_DEACTIVATE },
- { NM_ITEM, "", "R", 0, 0, (APTR) ID_REMOVE },
-
- { NM_ITEM, "", 0, 0, 0, (APTR) ID_ACTIVATESEL },
- { NM_ITEM, "", 0, 0, 0, (APTR) ID_DEACTIVATESEL },
- { NM_ITEM, "", 0, 0, 0, (APTR) ID_REMOVESEL },
-
- { NM_ITEM, "", "C", 0, 0, (APTR) ID_ACTIVATEALL },
- { NM_ITEM, "", "L", 0, 0, (APTR) ID_DEACTIVATEALL },
- { NM_ITEM, "", 0, 0, 0, (APTR) ID_REMOVEALL },
-
- { NM_ITEM, NM_BARLABEL, 0, 0, 0, 0 },
- { NM_ITEM, "", 0, 0, 0, 0 },
- { NM_SUB, "", "S", 0, 0, (APTR) ID_SHOW },
- { NM_SUB, "", 0, 0, 0, (APTR) ID_SHOWSEL },
- { NM_SUB, "", "H", 0, 0, (APTR) ID_HIDE },
- { NM_SUB, "", 0, 0, 0, (APTR) ID_HIDESEL },
-
- { NM_END, NULL, 0, 0, 0, 0 }
- };
-
- struct MUI_Command ARexxList[] =
- {
- { "select_name", "NAME/A", 1, &SelectNameRXHook},
- { "select_task", "TASKADR/N/A", 1, &SelectTaskRXHook},
-
- { "activate", MC_TEMPLATE_ID, ID_ACTIVATE, NULL},
- { "deactivate", MC_TEMPLATE_ID, ID_DEACTIVATE, NULL},
- { "activatesel", MC_TEMPLATE_ID, ID_ACTIVATESEL, NULL},
- { "deactivatesel", MC_TEMPLATE_ID, ID_DEACTIVATESEL, NULL},
- { "activateall", MC_TEMPLATE_ID, ID_ACTIVATEALL, NULL},
- { "deactivateall", MC_TEMPLATE_ID, ID_DEACTIVATEALL, NULL},
- { "remove", MC_TEMPLATE_ID, ID_REMOVE, NULL},
- { "removeall", MC_TEMPLATE_ID, ID_REMOVEALL, NULL},
- { "removesel", MC_TEMPLATE_ID, ID_REMOVESEL, NULL},
-
- { "interface_show", MC_TEMPLATE_ID, ID_SHOW, NULL},
- { "interface_hide", MC_TEMPLATE_ID, ID_HIDE, NULL},
- { "interface_showsel", MC_TEMPLATE_ID, ID_SHOWSEL, NULL},
- { "interface_hidesel", MC_TEMPLATE_ID, ID_HIDESEL, NULL},
-
- { NULL, NULL, 0, NULL}
- };
-
-
- static char *dedication = "Dedicated to Caruso";
-
- UWORD ExChangeSleepImg1Data[] =
- {
- 0x0003,0x8000,0x0000,0x0000,0x0004,0x4000,0x0000,0x0000,
- 0x0008,0x4000,0x0000,0x0000,0x0018,0x4de0,0x0000,0x0000,
- 0x0020,0x3210,0x0000,0x0000,0x0020,0x0008,0x0000,0x0000,
- 0x0020,0x0008,0x0000,0x0000,0x0020,0xf008,0x0000,0x0000,
- 0x0020,0x2788,0x0000,0x0000,0x0010,0x4108,0x0000,0x0000,
- 0x0010,0xf208,0x0000,0x0000,0x0008,0x0790,0x0000,0x0000,
- 0x0008,0x0020,0x0000,0x0000,0x003c,0x00c0,0x0000,0x0400,
- 0x0046,0x3f00,0x0000,0x0c00,0x0083,0xe008,0x0000,0x0c00,
- 0x0100,0x8038,0x0000,0x0c00,0x0101,0x00fc,0x0000,0x0c00,
- 0x0386,0x03fc,0x0000,0x0c00,0x04c8,0x0ff0,0x0000,0x0c00,
- 0x08b0,0x3ffc,0xc180,0x2c00,0x0500,0xffc0,0x6300,0x4c00,
- 0x0203,0xfd80,0x363c,0x8c00,0x000f,0xf180,0x1c41,0x0c00,
- 0x003f,0xc180,0x1c42,0x0c00,0x00ff,0x0180,0x3640,0x0c00,
- 0x03fc,0x00c0,0x6340,0x0c00,0x03f0,0x003c,0xc180,0x0c00,
- 0x01c0,0x0000,0x0080,0x0c00,0x0102,0x0000,0x0100,0x0c00,
- 0x0001,0x0000,0x0600,0x0c00,0x0000,0x9fff,0xf800,0x0c00,
- 0x0000,0x6000,0x0000,0x0c00,0x0000,0x2000,0x0000,0x0c00,
- 0x7fff,0xffff,0xffff,0xfc00,0x0003,0x8000,0x0000,0x0000,
- 0x0007,0xc000,0x0000,0x0000,0x000f,0xc000,0x0000,0x0000,
- 0x001f,0xcde0,0x0000,0x0000,0x003f,0xfff0,0x0000,0x0000,
- 0x003f,0xfff8,0x0000,0x0000,0x003f,0xfff8,0x0000,0x0000,
- 0x003f,0x0ff8,0x0000,0x0000,0x003f,0xd878,0x0000,0x0000,
- 0x001f,0xbef8,0x0000,0x0000,0x001f,0x0df8,0x0000,0x0000,
- 0x000f,0xf870,0x0000,0x0000,0x000f,0xffe0,0x0000,0x0000,
- 0xffff,0xffff,0xffff,0xf800,0xd57f,0xff51,0x5552,0x5000,
- 0xd5ff,0xf55f,0x8003,0x5000,0xd5ff,0xd527,0xbfff,0x9000,
- 0xd5ff,0x5482,0x7fff,0xd000,0xd7ff,0x5205,0xffff,0xe000,
- 0xd7fd,0x4813,0xffff,0xf000,0xdff5,0x2043,0x3e7f,0xd000,
- 0xd754,0x813f,0x9cff,0x9000,0xd752,0x047f,0xc9c3,0x5000,
- 0xd548,0x107e,0x2392,0x5000,0xd520,0x607e,0x2391,0x5000,
- 0xd481,0x3e7f,0xc995,0x5000,0xd204,0xff3f,0x9c95,0x5000,
- 0xc413,0xffc3,0x3e55,0x5000,0xde47,0xffff,0xff55,0x5000,
- 0xbf11,0xffff,0xfe55,0x5000,0xd854,0xffff,0xf955,0x5000,
- 0xc555,0x6000,0x0555,0x5000,0xd555,0x1555,0x5555,0x5000,
- 0xd555,0x5555,0x5555,0x5000,0x8000,0x0000,0x0000,0x0000,
- };
-
- struct Image ExChangeSleepImg1 =
- {
- 0x0000,0x0000,0x0036,0x0023,0x0002,
- &ExChangeSleepImg1Data[0],
- 0x03,0x00,0x00000000,
- };
-
- struct DiskObject ExchangeSleepDObj =
- {
- 0xe310,0x0001,
- 0x00000000,
- 0x00db,0x0050,0x0036,0x0024,0x0004,0x0003,0x0001,
- (APTR)&ExChangeSleepImg1,NULL,
- 0x00000000,0x00000000,0x00000000,
- 0x0000,
- 0x00000000,
- 0x0003,
- 0x00000000,0x00000000,0x80000000,0x80000000,
- 0x00000000,0x00000000,0x00000000,
- };
-
- struct DiskObject *ExchangeDObj;
-
- BOOL SetUpTimer(void)
- {
- if(TPort = CreateMsgPort())
- {
- TSignal = (1L << TPort -> mp_SigBit);
-
- if(TRequest = CreateIORequest(TPort, sizeof(struct timerequest)))
- {
- if(!OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)TRequest, 0))
- {
- TRequest -> tr_node . io_Command = TR_ADDREQUEST;
- TRequest -> tr_time . tv_secs = 1;
- TRequest -> tr_time . tv_micro = 0;
-
- SendIO((struct IORequest *)TRequest);
-
- return(TRUE);
- }
- DeleteIORequest(TRequest);
- }
- DeleteMsgPort(TPort);
- }
-
- return(FALSE);
- }
-
- void CloseTimer(void)
- {
- if(!(CheckIO((struct IORequest *)TRequest)))
- AbortIO((struct IORequest *)TRequest);
-
- WaitIO((struct IORequest *)TRequest);
- CloseDevice((struct IORequest *)TRequest);
-
- DeleteIORequest(TRequest);
-
- while(GetMsg(TPort))
- ;
-
- DeleteMsgPort(TPort);
- }
-
- LONG FindBrokerTask(ULONG t)
- {
- struct BrokerCopy *bc;
- LONG i;
-
- for(i=0;;i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- break;
-
- if(bc -> bc_Task == t)
- return(i);
- }
-
- return(-1);
- }
-
- LONG FindBrokerName(char *n)
- {
- struct BrokerCopy *bc;
- register int i;
-
- for(i=0;;i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- break;
-
- if(stricmp(&bc -> bc_Name[0], n) == 0)
- return((LONG)i);
- }
-
- return(-1);
- }
-
- void SetObjects(void)
- {
- struct BrokerCopy *bc;
- register int i;
- ULONG entries;
- LONG state;
- BOOL ende = FALSE;
-
- BOOL activate_able = TRUE, disable_interface = TRUE;
- BOOL disable_activate_sel = TRUE, disable_interface_sel = TRUE;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
-
- if(bc)
- {
- if(bc -> bc_Flags & COF_SHOW_HIDE)
- disable_interface = FALSE;
-
- if(!(bc -> bc_Flags & COF_ACTIVE))
- activate_able = FALSE;
- }
-
- get(LV_Broker, MUIA_List_Entries, &entries);
-
- for(i=0; i < entries; i++)
- {
- DoMethod(LV_Broker, MUIM_List_Select, i, MUIV_List_Select_Ask, &state);
-
- if(state)
- {
- disable_activate_sel = FALSE;
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- ende = TRUE;
-
- if(bc -> bc_Flags & COF_SHOW_HIDE)
- disable_interface_sel = FALSE;
- }
-
- if(ende)
- break;
- }
-
- if(set_able != activate_able)
- {
- SetAttrs(BT_Toggle, MUIA_NoNotify, TRUE, MUIA_Cycle_Active, activate_able ? 0 : 1, TAG_DONE);
- set_able = activate_able;
- }
-
- set(BT_Show, MUIA_Disabled, disable_interface);
- set(BT_Hide, MUIA_Disabled, disable_interface);
-
- set(BT_ActSel, MUIA_Disabled, disable_activate_sel);
- set(BT_RemoveSel, MUIA_Disabled, disable_activate_sel);
- set(BT_DeActSel, MUIA_Disabled, disable_activate_sel);
- set(BT_ShowSel, MUIA_Disabled, disable_interface_sel);
- set(BT_HideSel, MUIA_Disabled, disable_interface_sel);
-
-
- DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_ACTIVATE, activate_able);
- DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_DEACTIVATE, !activate_able);
-
- DoMethod(WN_Main, MUIM_Window_SetMenuState, ID_INTERFACE, !disable_interface);
- }
-
- void SetInfoText(void)
- {
- struct BrokerCopy *bc;
- UBYTE Buffer[600];
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
-
- sprintf(Buffer, "\0334%s\n\n\0330%s", bc -> bc_Title, bc -> bc_Descr);
- set(FT_Info, MUIA_Floattext_Text, Buffer);
- }
-
- RefreshBrokerList()
- {
- static UBYTE count;
-
- struct List *BrokerList;
- ULONG i;
- struct BrokerCopy *bc;
-
- if(BrokerList = AllocVec(sizeof(struct List), MEMF_PUBLIC))
- {
- struct Node *n, *nn;
- LONG pos, curs;
-
- count++;
-
- NewList(BrokerList);
-
- CopyBrokerList(BrokerList);
-
- get(LV_Broker, MUIA_List_Active, &curs);
-
- n = BrokerList->lh_Head;
-
- while (n && (nn = n->ln_Succ))
- {
- if((pos = FindBrokerName((char *)&((struct BrokerCopy *)n)->bc_Name[0])) >= 0)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
-
- bc -> bc_Flags = ((struct BrokerCopy *)n)->bc_Flags;
- bc -> bc_Node . ln_Type = count;
-
- if(curs == pos)
- SetObjects();
- }
- else
- {
- ((struct BrokerCopy *) n) -> bc_Node.ln_Type = count;
- DoMethod(LV_Broker, MUIM_List_Insert, &n, 1, MUIV_List_Insert_Sorted);
- }
-
- n = nn;
- }
-
- FreeBrokerList(BrokerList);
- FreeVec(BrokerList);
-
- for (i=0; ; i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if (!bc)
- break;
-
- if (bc->bc_Node.ln_Type != count)
- DoMethod(LV_Broker, MUIM_List_Remove, i--);
- }
- }
- return(TRUE);
- }
-
- MakeMUI()
- {
- UBYTE *Screen = ArgString(TTypes, "PUBSCREEN", "Workbench");
-
- if(AP_ExChange = ApplicationObject,
- MUIA_HelpFile, "ExChange.guide",
- MUIA_Application_Title, "ExChange",
- MUIA_Application_Version, "$VER: Exchange "VERSION" ("__DATE__")",
- MUIA_Application_Copyright, "© 1994-95 by T.O.M. Software",
- MUIA_Application_Author, "Marc-Christian Schröer",
- MUIA_Application_Description, GetExchangeString(AppDescription),
- MUIA_Application_Base, "EXCH",
- MUIA_Application_Menu, MenuList,
- MUIA_Application_Commands, ARexxList,
- MUIA_Application_BrokerHook, &BrokerListBrkHook,
- MUIA_Application_SingleTask, TRUE,
- MUIA_Application_DiskObject, ExchangeDObj,
-
- SubWindow, WN_Main = WindowObject,
- MUIA_HelpNode, "GADGETS",
- MUIA_Window_PublicScreen, Screen,
- MUIA_Window_ID, "MAIN",
- MUIA_Window_Title, "Exchange "VERSION" - © 1994-95 by Marc-Christian Schröer",
- MUIA_Window_NeedsMouseObject, TRUE,
- WindowContents, VGroup,
- Child, HGroup,
- Child, LV_Broker = ListviewObject,
- MUIA_Weight, 80,
- MUIA_Listview_DoubleClick, TRUE,
- MUIA_Listview_MultiSelect, MUIV_Listview_MultiSelect_Default,
- MUIA_Listview_List, ListObject,
- InputListFrame,
- MUIA_FrameTitle, GetExchangeString(CommList),
- MUIA_List_ConstructHook, &BrokerListConHook,
- MUIA_List_DestructHook, &BrokerListDesHook,
- MUIA_List_CompareHook, &BrokerListCmpHook,
- MUIA_List_DisplayHook, &BrokerListDspHook,
- MUIA_List_Format, "P=\0332,P=\0333\033r",
- MUIA_List_Title, TRUE,
- End,
- End,
- Child, VGroup,
- MUIA_Weight, 20,
- Child, FT_Info = ListviewObject,
- MUIA_Listview_List, FloattextObject,
- TextFrame,
- MUIA_FrameTitle, GetExchangeString(FrameInfo),
- MUIA_Floattext_Text, "",
- End,
- MUIA_Listview_Input,FALSE,
- End,
- Child, RegisterGroup(Pages),
- MUIA_Register_Frame, TRUE,
- Child, HGroup,
- MUIA_Group_SameWidth, TRUE,
- MUIA_Group_Columns, 2,
- Child, BT_Show = MUI_MakeObject(MUIO_Button, GetExchangeString(GadShowInterface)),
- Child, BT_Hide = MUI_MakeObject(MUIO_Button, GetExchangeString(GadHideInterface)),
- Child, BT_Toggle = KeyCycle(CycleEntries, *GetExchangeString(GadActivateKey)),
- Child, BT_Remove = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemove)),
- End,
- Child, VGroup,
- Child, HGroup,
- MUIA_Group_SameWidth, TRUE,
- MUIA_Group_Columns, 2,
- Child, BT_ShowSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadShowInterfaceSel)),
- Child, BT_HideSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadHideInterfaceSel)),
- Child, BT_ActSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadActivateSel)),
- Child, BT_DeActSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadDeActivateSel)),
- End,
- Child, BT_RemoveSel = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemoveSel)),
- End,
- Child, HGroup,
- MUIA_Group_SameWidth, TRUE,
- MUIA_Group_Columns, 1,
- Child, BT_ActAll = MUI_MakeObject(MUIO_Button, GetExchangeString(GadActivateAll)),
- Child, BT_DeActAll = MUI_MakeObject(MUIO_Button, GetExchangeString(GadDeActivateAll)),
- Child, BT_RemoveAll = MUI_MakeObject(MUIO_Button, GetExchangeString(GadRemoveAll)),
- End,
- End,
- Child, HGroup,
- MUIA_Group_SameWidth, TRUE,
- Child, BT_Icon = MUI_MakeObject(MUIO_Button, GetExchangeString(GadIconify)),
- Child, BT_Quit = MUI_MakeObject(MUIO_Button, GetExchangeString(GadQuit)),
- End,
- End,
- End,
-
- Child, HGroup,
- Child, MUI_MakeObject(MUIO_Label, GetExchangeString(GadDesc), 0),
- Child, TX_Desc = TextObject,
- MUIA_Text_PreParse, "\0333",
- MUIA_InnerLeft, 0,
- MUIA_InnerRight, 0,
- ReadListFrame,
- End,
- End,
- End,
- End,
- End)
- {
- DoMethod(WN_Main, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, AP_ExChange, 2, MUIM_Application_ReturnID, ID_ICONIFY);
-
- DoMethod(LV_Broker, MUIM_Notify, MUIA_Listview_SelectChange, TRUE, AP_ExChange, 2, MUIM_Application_ReturnID, ID_LV_ACTIVE);
- DoMethod(LV_Broker, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, AP_ExChange, 2, MUIM_Application_ReturnID, ID_LV_ACTIVE);
- DoMethod(LV_Broker, MUIM_Notify, MUIA_Listview_DoubleClick, TRUE, AP_ExChange, 2, MUIM_Application_ReturnID, ID_DOUBLE);
- DoMethod(AP_ExChange, MUIM_Notify, MUIA_Application_MenuHelp, MUIV_EveryTime, AP_ExChange, 2, MUIM_Application_ReturnID, ID_MENUHELP);
- DoMethod(WN_Main, MUIM_Notify, MUIA_Window_MouseObject, MUIV_EveryTime, TX_Desc, 3, MUIM_CallHook, &MouseHook, MUIV_TriggerValue);
-
- SetCycID(AP_ExChange, BT_Toggle, ID_TOGGLE);
- SetButID(AP_ExChange, BT_Remove, ID_REMOVE);
- SetButID(AP_ExChange, BT_Hide, ID_HIDE);
- SetButID(AP_ExChange, BT_Show, ID_SHOW);
-
- SetButID(AP_ExChange, BT_DeActAll, ID_DEACTIVATEALL);
- SetButID(AP_ExChange, BT_ActAll, ID_ACTIVATEALL);
- SetButID(AP_ExChange, BT_RemoveAll, ID_REMOVEALL);
-
- SetButID(AP_ExChange, BT_ActSel, ID_ACTIVATESEL);
- SetButID(AP_ExChange, BT_DeActSel, ID_DEACTIVATESEL);
- SetButID(AP_ExChange, BT_RemoveSel, ID_REMOVESEL);
- SetButID(AP_ExChange, BT_HideSel, ID_HIDESEL);
- SetButID(AP_ExChange, BT_ShowSel, ID_SHOWSEL);
-
- SetButID(AP_ExChange, BT_Icon, ID_ICONIFY);
- SetButID(AP_ExChange, BT_Quit, ID_QUIT);
-
- set(FT_Info, MUIA_UserData, GetExchangeString(DescInfo));
- set(LV_Broker, MUIA_UserData, GetExchangeString(DescBroker));
- set(BT_Toggle, MUIA_UserData, GetExchangeString(DescToggle));
- set(BT_Remove, MUIA_UserData, GetExchangeString(DescRemove));
- set(BT_Show, MUIA_UserData, GetExchangeString(DescShow));
- set(BT_Hide, MUIA_UserData, GetExchangeString(DescHide));
- set(BT_DeActAll, MUIA_UserData, GetExchangeString(DescDeActAll));
- set(BT_ActAll, MUIA_UserData, GetExchangeString(DescActAll));
- set(BT_Icon, MUIA_UserData, GetExchangeString(DescIcon));
- set(BT_Quit, MUIA_UserData, GetExchangeString(DescQuit));
- set(BT_RemoveAll, MUIA_UserData, GetExchangeString(DescRemoveAll));
- set(BT_ActSel, MUIA_UserData, GetExchangeString(DescActSel));
- set(BT_DeActSel, MUIA_UserData, GetExchangeString(DescDeActSel));
- set(BT_RemoveSel, MUIA_UserData, GetExchangeString(DescRemoveSel));
- set(BT_ShowSel, MUIA_UserData, GetExchangeString(DescShowSel));
- set(BT_HideSel, MUIA_UserData, GetExchangeString(DescHideSel));
- set(TX_Desc, MUIA_UserData, GetExchangeString(DescDesc));
-
- DoMethod(WN_Main, MUIM_Window_SetCycleChain, LV_Broker, FT_Info, BT_Toggle, BT_Remove, BT_Hide, BT_Show, BT_ActAll, BT_DeActAll, BT_RemoveAll, BT_Icon, BT_Quit, NULL);
-
- return(TRUE);
- }
- return(FALSE);
- }
-
- void About()
- {
- MUI_Request(AP_ExChange, WN_Main, 0, "ExChange Info", "*Ok", GetExchangeString(InfoText));
- }
-
- BOOL SetUpBroker()
- {
- CxObj *MyBroker, *Sender, *Hotkey, *Translate;
- struct MsgPort *BrokerPort;
-
- get(AP_ExChange, MUIA_Application_Broker, &MyBroker);
- get(AP_ExChange, MUIA_Application_BrokerPort, &BrokerPort);
-
- SetCxObjPri(MyBroker, ArgInt(TTypes, "CX_PRIORITY", 0));
-
- if(Hotkey = CxFilter(ArgString(TTypes, "CX_POPKEY", "alt help")))
- {
- AttachCxObj(MyBroker, Hotkey);
-
- if(Sender = CxSender(BrokerPort, ID_HOTKEY))
- {
- AttachCxObj(Hotkey, Sender);
-
- if(Translate = CxTranslate(NULL))
- {
- AttachCxObj(Hotkey, Translate);
- return(TRUE);
- }
- }
- DeleteCxObj(Hotkey);
- }
-
- return(FALSE);
- }
-
- void SetUpMenus()
- {
- MenuList[0] . nm_Label = GetExchangeString(MenuProject);
- MenuList[1] . nm_Label = GetExchangeString(MenuProjectAbout);
- MenuList[3] . nm_Label = GetExchangeString(MenuProjectIconify);
- MenuList[4] . nm_Label = GetExchangeString(MenuProjectQuit);
- MenuList[5] . nm_Label = GetExchangeString(MenuBroker);
- MenuList[6] . nm_Label = GetExchangeString(MenuBrokerActivate);
- MenuList[7] . nm_Label = GetExchangeString(MenuBrokerDeActivate);
- MenuList[8] . nm_Label = GetExchangeString(MenuBrokerRemove);
- MenuList[9] . nm_Label = GetExchangeString(MenuBrokerActivateSel);
- MenuList[10] . nm_Label = GetExchangeString(MenuBrokerDeActivateSel);
- MenuList[11] . nm_Label = GetExchangeString(MenuBrokerRemoveSel);
- MenuList[12] . nm_Label = GetExchangeString(MenuBrokerActivateAll);
- MenuList[13] . nm_Label = GetExchangeString(MenuBrokerDeActivateAll);
- MenuList[14] . nm_Label = GetExchangeString(MenuBrokerRemoveSel);
- MenuList[16] . nm_Label = GetExchangeString(MenuBrokerInterface);
- MenuList[17] . nm_Label = GetExchangeString(MenuBrokerInterfaceShow);
- MenuList[18] . nm_Label = GetExchangeString(MenuBrokerInterfaceShowSel);
- MenuList[19] . nm_Label = GetExchangeString(MenuBrokerInterfaceHide);
- MenuList[20] . nm_Label = GetExchangeString(MenuBrokerInterfaceHideSel);
-
- Pages[0] = GetExchangeString(GroupSingle);
- Pages[1] = GetExchangeString(GroupSelected);
- Pages[2] = GetExchangeString(GroupAll);
- Pages[3] = NULL;
-
- CycleEntries[0] = GetExchangeString(GadDeActivate);
- CycleEntries[1] = GetExchangeString(GadActivate);
- CycleEntries[2] = NULL;
- }
-
- int main(int argc, UBYTE **argv)
- {
- ULONG signals, retsignals, running = TRUE, pos;
- struct BrokerCopy *bc;
- register int i;
- char *IconfileName;
-
- if(IconBase = OpenLibrary("icon.library",0))
- {
- ExchangeDObj = &ExchangeSleepDObj;
-
- LocaleBase = OpenLibrary("locale.library",0);
- OpenExchangeCatalog(NULL, NULL);
-
- if(CxBase = OpenLibrary("commodities.library",0))
- {
- TTypes = ArgArrayInit(argc, argv);
-
- AppIcon = (!stricmp((char *)ArgString(TTypes, "APPICON", "ON"), "ON"));
-
- if(strlen(IconfileName = ArgString(TTypes, "ICONFILE", "")))
- {
- if(stricmp(strrchr((char *)IconfileName, '.'),".info") == 0)
- *strrchr((char *)IconfileName, '.') = 0x00;
-
- if(!(ExchangeDObj = GetDiskObject(IconfileName)))
- ExchangeDObj = &ExchangeSleepDObj;
- }
-
- // for some strange reasons, this does not work
-
- ExchangeDObj -> do_CurrentX = ArgInt(TTypes, "ICONPOS_X", NO_ICON_POSITION);
- ExchangeDObj -> do_CurrentY = ArgInt(TTypes, "ICONPOS_Y", NO_ICON_POSITION);
- ExchangeDObj -> do_Type = 0;
-
- if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))
- {
- if(MUIMasterBase = OpenLibrary("muimaster.library",0))
- {
- if(SetUpTimer())
- {
- SetUpMenus();
-
- if(MakeMUI())
- {
- if(SetUpBroker())
- {
- RefreshBrokerList();
- SetObjects();
- SetInfoText();
-
- set(LV_Broker, MUIA_List_Active, 0);
-
- if(strnicmp((char *)ArgString(TTypes, "CX_POPUP", "YES"), "Y", 1))
- {
- if(AppIcon)
- {
- set(AP_ExChange, MUIA_Application_Iconified, TRUE);
- set(WN_Main, MUIA_Window_Open, TRUE);
- }
- }
- else
- {
- set(WN_Main, MUIA_Window_Open, TRUE);
- set(WN_Main, MUIA_Window_ActiveObject, LV_Broker);
- }
-
- while(running)
- {
- switch(DoMethod(AP_ExChange, MUIM_Application_Input, &signals))
- {
- case ID_MENUHELP: DoMethod(AP_ExChange, MUIM_Application_ShowHelp, NULL, "ExChange.guide", "MENUS", 0);
- break;
-
- case ID_ABOUT: About();
- break;
-
- case ID_LV_ACTIVE: SetObjects();
- SetInfoText();
- break;
-
- case ID_TOGGLE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
-
- if(bc -> bc_Flags & COF_ACTIVE)
- {
- bc -> bc_Flags &= ~COF_ACTIVE;
- BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
- }
- else
- {
- bc -> bc_Flags |= COF_ACTIVE;
- BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
- }
- SetObjects();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
- break;
-
- case ID_ACTIVATESEL: for(pos = -1;pos != -1;)
- {
- DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
-
- if(pos == -1)
- break;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
- }
- RefreshBrokerList();
- SetObjects();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
- break;
-
- case ID_DEACTIVATESEL:for(pos = -1;pos != -1;)
- {
- DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
-
- if(pos == -1)
- break;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
- }
- SetObjects();
- RefreshBrokerList();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
- break;
-
- case ID_SHOWSEL: for(pos = -1;pos != -1;)
- {
- DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
-
- if(pos == -1)
- break;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
- }
- break;
-
- case ID_HIDESEL: for(pos = -1;pos != -1;)
- {
- DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
-
- if(pos == -1)
- break;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_DISAPPEAR);
- }
- break;
-
-
- case ID_REMOVESEL: for(pos = -1;pos != -1;)
- {
- DoMethod(LV_Broker, MUIM_List_NextSelected, &pos);
-
- if(pos == -1)
- break;
-
- DoMethod(LV_Broker, MUIM_List_GetEntry, pos, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_KILL);
- }
- SetObjects();
- RefreshBrokerList();
- break;
-
- case ID_DEACTIVATE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
- break;
-
- case ID_ACTIVATE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_Active);
- break;
-
- case ID_DEACTIVATEALL:for(i=0;;i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- break;
-
- BrokerCommand(bc -> bc_Name, CXCMD_DISABLE);
- }
- SetObjects();
- RefreshBrokerList();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
- break;
-
- case ID_ACTIVATEALL: for(i=0;;i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- break;
-
- BrokerCommand(bc -> bc_Name, CXCMD_ENABLE);
- }
- SetObjects();
- RefreshBrokerList();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
- break;
-
- case ID_REMOVEALL: for(i=0;;i++)
- {
- DoMethod(LV_Broker, MUIM_List_GetEntry, i, &bc);
-
- if(!bc)
- break;
-
- BrokerCommand(bc -> bc_Name, CXCMD_KILL);
- }
- SetObjects();
- RefreshBrokerList();
- DoMethod(LV_Broker, MUIM_List_Redraw, MUIV_List_Redraw_All);
- break;
-
- case ID_REMOVE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_KILL);
- break;
-
- case ID_SHOW: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
- break;
-
- case ID_DOUBLE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- if(bc -> bc_Flags & COF_SHOW_HIDE)
- BrokerCommand(bc -> bc_Name, CXCMD_APPEAR);
- break;
-
- case ID_HIDE: DoMethod(LV_Broker, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &bc);
- BrokerCommand(bc -> bc_Name, CXCMD_DISAPPEAR);
- break;
-
- case ID_ICONIFY: if(AppIcon)
- set(AP_ExChange, MUIA_Application_Iconified, TRUE);
- else
- set(WN_Main, MUIA_Window_Open, FALSE);
- break;
- case ID_QUIT:
- case MUIV_Application_ReturnID_Quit: running = FALSE;
- break;
- }
-
- if(running && signals)
- retsignals = Wait(signals | TSignal);
-
- if(retsignals & TSignal)
- {
- while(GetMsg(TPort))
- ;
-
- RefreshBrokerList();
-
- TRequest -> tr_node . io_Command = TR_ADDREQUEST;
- TRequest -> tr_time . tv_secs = 1;
- TRequest -> tr_time . tv_micro = 0;
-
- SendIO((struct IORequest *)TRequest);
- }
- }
- }
-
- MUI_DisposeObject(AP_ExChange);
- }
-
- CloseTimer();
- }
- CloseLibrary((struct Library *)MUIMasterBase);
- ArgArrayDone();
- }
- CloseLibrary((struct Library *)IntuitionBase);
- }
- CloseLibrary((struct Library *)CxBase);
-
- if(ExchangeDObj != &ExchangeSleepDObj)
- if(ExchangeDObj)
- FreeDiskObject(ExchangeDObj);
- }
-
- if(LocaleBase) CloseLibrary(LocaleBase);
-
- CloseExchangeCatalog();
- CloseLibrary(IconBase);
- }
- }
-